/**
 * 登录
 * @date 2016/05/4
 */
function login() {
    var warmColor = '#fb511e';
    var phone = $("#usephone").val();
    var pwd = $("#password").val();
    if (!phone) {
        layer.tips('请输入用户名！', '#usephone');
        return;
    }
    if (!pwd) {
        layer.tips('请输入密码！', '#password');
        return;
    }
    var param = JSON.stringify({"phone": phone, "password": hex_md5(pwd)});

    $.ajax({
        url: "/login/login",
        dataType: 'json',
        type: 'post',
        data: param,
        success: function (data) {
            if (data.status == 0) {
                window.location = "/index/index";
            } else {
                bbx_alert_error(data.message);
            }
        },
        error: function (data) {
            console.log(data);
            bbx_alert_error(data.message);
        }

    });
}



$(window).load(function () {
    $(document).on('keyup', function (e) {
        if (e.keyCode === 13) {
            login();
        }
    });
    $(".login-btn").click(function () {
        login();
    })
});
